#include <iostream>
#include <string>
#include <unordered_map>
#include <cmath>

bool is_prime(int num) {
    if (num < 2) {
        return false;
    }
    for (int i = 2; i <= static_cast<int>(std::sqrt(num)); ++i) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

std::string find_nearest_prime(const std::string& word_num) {
    std::unordered_map<std::string, std::string> num_dict = {
        {"zero", "0"}, {"one", "1"}, {"two", "2"}, {"three", "3"}, {"four", "4"},
        {"five", "5"}, {"six", "6"}, {"seven", "7"}, {"eight", "8"}, {"nine", "9"}
    };

    std::string num_str;
    size_t pos = 0, found;
    while ((found = word_num.find(' ', pos)) != std::string::npos) {
        std::string word = word_num.substr(pos, found - pos);
        num_str += num_dict[word];
        pos = found + 1;
    }
    num_str += num_dict[word_num.substr(pos)];

    if (num_str.length() != 3 || !std::all_of(num_str.begin(), num_str.end(), ::isdigit)) {
        return "Wrong input";
    }

    int num = std::stoi(num_str);
    int a = num;
    int b = num;

    while (true) {
        if (is_prime(a)) {
            return std::to_string(a);
        }
        if (is_prime(b)) {
            return std::to_string(b);
        }
        --a;
        ++b;
    }
}

int main() {
    std::string word_num;
    std::getline(std::cin, word_num);
    std::cout << find_nearest_prime(word_num) << std::endl;
    return 0;
}


